Org2XM v1.0
===========

 Converts Organya song files to XM modules.
 Implementation 2008-04-02 by Jan "Rrrola" Kadlec <rrrola@gmail.com>.
 Public Domain.

 This program converts ripped music from Cave story into XM modules.
 It finds the best BPM/tempo combination, optimizes finetune for every
 note and instrument and collapses duplicate patterns. C source included.
 Enjoy!


Usage
-----

 First unpack melody samples by running "wave100.exe" in the directory
 "samples". Then convert any Organya song by using

 org2xm.exe input.org [compatibility]

 If you add a second parameter, the instrument number will be reset on every
 note. This is more compatible (some players don't support running 8xx),
 but since it resets both volume and panning, is may not be possible to use
 finetune so often. The encoder will balance it as much as possible.

 Batch files are included for all Cave Story songs.


ORG file format
---------------

 Header:

 offset|type...|name............|description

     0  byte    magic[6]         "Org-02"
     6  word    msPerBeat        1..2000
     8  byte    measuresPerBar  \
     9  byte    beatsPerMeasure _only a few combinations are allowed
    10  dword   loopStart       \
    12  dword   loopEnd         _in beats

 Instruments (0..7 melody, 8..15 drums):

 16+6i  word    frequencyShift
    +2  byte    sample           melody 0..99, drums 0..11
    +3  byte    noLoop           for melody voices: don't loop
    +4  word    n[i]             number of notes

 For every instrument:

 112+?  n*dword startBeat
   +4n  n*byte  key              0(C0)..96(B7) (255 = change vol/pan)
   +5n  n*byte  length           in beats
   +6n  n*byte  volume           0..252 (255 = no change)
   +7n  n*byte  panning          0=left..6=center..12=right (255 = no change)

 Note frequencies (in Hz):
  melody: f = 8363 * 2^(key/12) + frequencyShift - 1000
  drums:  f = 800 * key + frequencyShift - 900

 Volume and panning is linearly streched into the XM range. That may not be
 entirely correct (volume is supposed to be logarithmic), but it sounds
 the best.

 The melody samples are signed 16-bit, MSB first.


Thanks
------

 - Pixel for making Cave Story and composing all the songs
 - Pete Mackay for providing details about the original Org player routine
